//============================================================================
// Copyright (C) 2013 Brett R. Jones
//
// Issued to public domain 2013
//
// brettjones1900@gmail.com
// http://www.p2panarchy.com
//============================================================================
#include "VxRelayFlags.h"

#define RC_PROXY_FLAG_REQUIRES_PROXY			0x01	// user requires proxy to connect to him
#define RC_PROXY_FLAG_HAS_PROXY					0x02	// user has at least one proxy that may be used to connect to him
#define RC_PROXY_FLAG_IS_MY_PREFERED_PROXY		0x04	// user is a proxy for others
#define RC_PROXY_FLAG_USE_ENCRYPTION			0x08	// user wants encrypted traffic

//////////////////////////////////////////////////////////////////////////////

//=== constructor ===//
VxRelayFlags::VxRelayFlags() : m_u8RelayFlags(0){}

//! return true if has any proxies
bool	VxRelayFlags::hasRelayFlags( void )					{ return (m_u8RelayFlags)?1:0; }
//! return true if has any proxies
bool	VxRelayFlags::hasRelay( void )						{ return (RC_PROXY_FLAG_HAS_PROXY & m_u8RelayFlags)?1:0; }
//! set has image files
void	VxRelayFlags::setHasRelay( bool bHasRelay )				
{
	if( bHasRelay )
		m_u8RelayFlags |= RC_PROXY_FLAG_HAS_PROXY;
	else
		m_u8RelayFlags &= ~RC_PROXY_FLAG_HAS_PROXY;
}
//! return true if has any shared files
bool	VxRelayFlags::requiresRelay( void )					{ return (RC_PROXY_FLAG_REQUIRES_PROXY & m_u8RelayFlags)?1:0; }
//! set requires proxy
void	VxRelayFlags::setRequiresRelay( bool bRequiresRelay )				
{
	if( bRequiresRelay )
		m_u8RelayFlags |= RC_PROXY_FLAG_REQUIRES_PROXY;
	else
		m_u8RelayFlags &= ~RC_PROXY_FLAG_REQUIRES_PROXY;
}
//! return true if has any shared files
bool	VxRelayFlags::isMyPreferedRelay( void )					{ return (RC_PROXY_FLAG_IS_MY_PREFERED_PROXY & m_u8RelayFlags)?1:0; }
//! set requires proxy
void	VxRelayFlags::setIsMyPreferedRelay( bool bRequiresRelay )				
{
	if( bRequiresRelay )
		m_u8RelayFlags |= RC_PROXY_FLAG_IS_MY_PREFERED_PROXY;
	else
		m_u8RelayFlags &= ~RC_PROXY_FLAG_IS_MY_PREFERED_PROXY;
}